package org.example.service.impl;

import com.google.gson.Gson;
import jakarta.annotation.Resource;
import org.example.mapper.VolunteerAnalyzeMapper;
import org.example.pojo.ListMap;
import org.example.pojo.Volunteer;
import org.example.service.VolunteerDataAnalyzeService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author:曹震
 * @Date: 2024/12/4 17:04
 */

@Service
public class VolunteerDataAnalyze implements VolunteerDataAnalyzeService {
    @Resource
    private VolunteerAnalyzeMapper mapper;
    @Override
    public List<Volunteer> sortVolunteers() {
        List<Volunteer> volunteers = mapper.sortListVolunteer();
       return volunteers;
    }
    @Override
    public Volunteer listVolunteerTask(String volunteerId) {
        Volunteer volunteer = mapper.listVolunteerTask(volunteerId);
        return volunteer;
    }

    @Override
    public String listMap(String volunteerId) {
        HashMap<String, List<ListMap>> stringListMapHashMap = new HashMap<>();
        //第一种：志愿者评价
        List<ListMap>list=mapper.accountVolunteersEvaluate(volunteerId);
        //任务种类分布
        List<ListMap> listMaps = mapper.accountTaskType(volunteerId);
        stringListMapHashMap.put("志愿者评价等级统计", list);
        stringListMapHashMap.put("任务种类分布", listMaps);
        Gson gson = new Gson();
        String json = gson.toJson(stringListMapHashMap);
        return json;
    }

    @Override
    public List<Map<String,Integer>> showActiveMap() {
        List<Map<String, Integer>> maps = mapper.activeMap();
        System.out.println(maps);
        return maps;
    }
}

//        charData2.setMapName("志愿者评价等级统计");
//        int fiveStar  = mapper.findFiveStar(volunteerId);
//        int fourStar  = mapper.findFourStar(volunteerId);
//        int thereStar = mapper.findThereStar(volunteerId);
//        int towStar   = mapper.findTowStar(volunteerId);
//        int oneStar   = mapper.findOneStar(volunteerId);
//        PieChartData pieChartData  = new PieChartData("五星评价",fiveStar);
//        PieChartData pieChartData1 = new PieChartData("四星评价", fourStar);
//        PieChartData pieChartData2 = new PieChartData("三星评价", thereStar);
//        PieChartData pieChartData3 = new PieChartData("二星评价", towStar);
//        PieChartData pieChartData4 = new PieChartData("一星评价", oneStar);
//        List<PieChartData> list = Arrays.asList(pieChartData, pieChartData1, pieChartData2, pieChartData3, pieChartData4);
//        charData2.setPieChartData(list);